<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="project.pojo.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: d11yu
  Date: 2022/4/10
  Time: 11:16
  To change this template use File | Settings | File Templates.
  注意需要引入以下依赖：

  <dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-impl</artifactId>
    <version>1.2.5</version>
    <scope>runtime</scope>
</dependency>

<dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-spec</artifactId>
    <version>1.2.5</version>
</dependency>

--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        table {
            border-collapse: collapse;
        }

        th, td {
            border: black solid 1px;
        }
    </style>
</head>
<body>
c:set <br>
<c:set scope="request" var="k1" value="v1"/>
k1: ${requestScope.k1} <br>
<hr>
c:if <br>
<c:if test="${12==12}">
    12等于12 <br>
</c:if>
<c:if test="${12!=12}">
    12不等于12 <br>
</c:if>
<hr>
c:choose <br>
<%
    request.setAttribute("height", 178);
%>
<c:choose>
    <c:when test="${requestScope.height > 190}">
        大于190 <br>
    </c:when>
    <c:when test="${requestScope.height > 180}">
        大于180 <br>
    </c:when>
    <c:when test="${requestScope.height > 170}">
        大于170 <br>
    </c:when>
    <c:otherwise>
        小于等于170 <br>
    </c:otherwise>
</c:choose>
<hr>
c:forEach <br>
1. 遍历 1 到 10，输出 <br>
<c:forEach begin="1" end="10" var="i">
    ${i}
</c:forEach>
<hr>
2. 遍历 Object 数组 <br>
<%
    request.setAttribute("arr", new String[]{"abc", "bca", "dfd"});
%>
<c:forEach items="${requestScope.arr}" var="item">
    ${item},
</c:forEach>
<hr>
3. 遍历 Map 集合 <br>
<%
    Map<String, String> map = new HashMap<>();
    map.put("k1", "v1");
    map.put("k2", "v2");
    map.put("k3", "v3");
    request.setAttribute("map", map);
%>
<c:forEach items="${requestScope.map}" var="item">
    ${item}: key: ${item.key}, value: ${item.value} <br>
</c:forEach>
<hr>
4. 遍历 List 集合---list 中存放 Student 类，有属性：编号，用户名，密码，年龄， 电话信息 <br>
<%
    List<Student> students = new ArrayList<>();
    for (int i = 1; i <= 10; i++) {
        students.add(new Student(i, "name" + i, i + 18, "phone" + i));
    }
    request.setAttribute("students", students);
%>
<table>
    <tr>
        <th>id</th>
        <th>name</th>
        <th>age</th>
        <th>phone</th>
        <th>status.current</th>
        <th>status.index</th>
        <th>status.count</th>
        <th>status.first</th>
        <th>status.last</th>
        <th>status.begin</th>
        <th>status.end</th>
        <th>status.step</th>
        <th>操作</th>
    </tr>
    <c:forEach begin="0" end="100" varStatus="status" items="${students}" var="student">
        <tr>
            <td>${student.id}</td>
            <td>${student.name}</td>
            <td>${student.age}</td>
            <td>${student.phone}</td>
            <td>${status.current}</td>
            <td>${status.index}</td>
            <td>${status.count}</td>
            <td>${status.first}</td>
            <td>${status.last}</td>
            <td>${status.begin}</td>
            <td>${status.end}</td>
            <td>${status.step}</td>
            <td>删除、修改</td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
